//
// Created by Win on 2015/11/30.
//

#ifndef __CORBA_COMM_H_
#define __CORBA_COMM_H_


#include "frlist.h"
#include "frreport_comm.h"
#include "frbyte_buffer.h"

#define WLS_PTOP                       0
#define WLS_SUB                         1
#define WLS_NOTIFY                    2

#define WEBLOGIC_JMS_PUSHREQUEST           "RMI:weblogic.jms.common.JMSPushRequest"

#define CORBA_IDL_STRINGVALUE      "IDL:omg.org/CORBA/WStringValue:1.0"
#define EJB_FUNC                      "request.ejb.function"
#define EJB_FUNC_RESP                 "response.ejb.function"

typedef struct __st_wls_jms_session
{
    char *p_queue;                          // 队列名
    char *p_title;                          // title
    char *p_weblogic_server;
    char *p_jms_server;
    char *p_jms_module;
} Wls_jms_session;

typedef struct __st_wls_jms_info
{
    int is_topic;
    int i_type;
    int i_start_pos;
    Wls_jms_session *p_st_session;
} Wls_jms_info;

typedef struct __st_L7session_corba_private
{
	unsigned long ul_seq;                             /* 序列号，1次req和response时，使用同一个序列号 */
	Frlist_header *p_lst_comm_tmp;                          //数据  corba comm
	Frlist_header *p_lst_req_tmp;                          //数据  corba req
	Frlist_header *p_lst_mq_tmp;                          //数据  corba mq

	Frreport_body_data *p_st_body_data_req;
	Frreport_body_data *p_st_body_data_resp;

	L4_transaction st_l4_trans;                         /* 数据 */

	int i_request_id;
	int i_response_required;
	int i_endianess;
	int i_version;
	int i_data_len;

	char *p_server;
	char *p_title;

	long l_response_code;

        int i_message_type;

}L7session_corba_private;


typedef struct __st_session_info
{
	Frbyte_Packet *p_st_data;
	int i_data_len;                                    /* 数据长度 */
	char arr_session_id[APM_UUID_SIZE];

	L7session_corba_private *p_st_private;
	L4_transaction st_l4_trans;                      /*response 是 记录时间参数使用  request 直接用L7session_corba_private 中的p_st_l4_trans*/

	int i_flag_weblogic;

	int is_wls_ejb;
	char *p_wls_ejbname;
	char *p_wls_function;

	int is_wls_jms;
	Wls_jms_info *p_st_jms;

//	int i_flag_was;

        int is_was_ejb;
	char *p_key_address;
	int i_key_addr_len;

	char *p_was_function;

	int i_pos;

	Frlist_header st_private;
}corba_session;


int corba_request_parse(Frbyte_Packet *p_st_data, Frreport_body_data *p_st_body_data, corba_session *p_st_session_private);
int corba_response_parse(Frbyte_Packet *p_st_data, Frreport_body_data *p_st_body_data, corba_session *p_st_session_private);
int skip_utf(Frbyte_Packet *p_st_data);
int giop_get_private(Frbyte_Packet *p_packet, corba_session *p_session_private);
#endif //APM_R2_CORBA_COMM_H
